﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SARUserControls
{
	/// <summary>
	/// HuiboMoniProgressBar.xaml 的交互逻辑
	/// </summary>
	public partial class HuiboMoniProgressBar : UserControl
	{
		public HuiboMoniProgressBar()
		{
			this.InitializeComponent();
		}

        private double progressValue = 0;
        /// <summary>
        /// 进度值
        /// </summary>
        public double SARProgressValue
        {
            get { return progressValue; }
            set
            {
                if (value < 0)
                {
                    value = 0;
                }
                else if (value > 1)
                {
                    value = 1;
                }
                progressValue = value;
                gridProgress.Width = 465 * value;
            }
        }

        public event MouseButtonEventHandler SARStartClick;
        private void mousecapture_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!startEnabled)
            {
                return;
            }
            this.pathIcon.Margin = new Thickness(28.2044677734375, 21.04541015625, 0, 0);
            if (SARStartClick != null)
            {
                SARStartClick.Invoke(this, e);
            }
        }

        private void mousecapture_MouseLeave(object sender, MouseEventArgs e)
        {
            if (!startEnabled)
            {
                return;
            }
            this.pathIcon.Margin = new Thickness(27.2044677734375, 20.04541015625, 0, 0);
        }

        private void mousecapture_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!startEnabled)
            {
                return;
            }
            this.pathIcon.Margin = new Thickness(27.2044677734375, 20.04541015625, 0, 0);
        }

        private bool startEnabled = true;
        public bool SARStartEnabled
        {
            get { return startEnabled; }
            set
            {
                startEnabled = value;
                if (value)
                {
                    this.gridStart.Opacity = 1;
                }
                else
                {
                    this.gridStart.Opacity = 0.5;
                }
            }
        }
	}
}